package com.mindskip.xzs.utility.excel;

import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import org.apache.poi.ss.usermodel.Sheet;

/**
 * 默认filter
 */
public class FreezeAndFilter implements SheetWriteHandler {

    private int colSplit = 0, rowSplit = 0, leftmostColumn = 0, topRow = 0;

    public FreezeAndFilter(Integer frozenRows) {
        if (frozenRows == null || frozenRows < 0) {
            frozenRows = 0;
        }
        this.rowSplit = frozenRows;
        this.topRow = frozenRows;
    }

    public FreezeAndFilter(){}

    @Override
    public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {

    }

    @Override
    public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
        Sheet sheet = writeSheetHolder.getSheet();
        sheet.createFreezePane(colSplit, rowSplit, leftmostColumn, topRow);
    }
}
